package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type loginForm struct{
	User string `json:"user" binding:"required,min=3,max=10"`
	Password string `json:"password" binding:"required"`
}


func main(){
	router := gin.Default()

	router.POST("/login", login)

	router.Run(":8686")
}

func login(c *gin.Context) {
	var loginInfo loginForm
	if err := c.ShouldBind(&loginInfo); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"err": err.Error(),
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"message": "登录成功",
	})
}
